package com.pattern.Singlenton.hangry;

/**
 * @Author Administrator
 * @CreateTime 2020/10/15 - 09:32
 * 单例模式-饿汉式
 */
public class MyHangrySingleton {
    private static MyHangrySingleton instance = new MyHangrySingleton();
    private MyHangrySingleton(){}
    public static MyHangrySingleton getInstance(){
        return instance;
    }
}
class MyHangrySingletonTest{
    public static void main(String[] args) {
        MyHangrySingleton singleton1 = MyHangrySingleton.getInstance();
        MyHangrySingleton singleton2 = MyHangrySingleton.getInstance();
        System.out.println(singleton1 == singleton2);
    }
}
